<?php
session_start();
// store session data
$op = $_REQUEST['op'];
switch ($op) {
	case 'add':
		$_SESSION['views'] += 1;
		break;
	case 'sub':
		$_SESSION['views'] -= 1;
		break;
	case 'logout':
		$_SESSION = array();
		
		// If it's desired to kill the session, also delete the session cookie.
		// Note: This will destroy the session, and not just the session data!
		if (ini_get("session.use_cookies")) {
		    $params = session_get_cookie_params();
		    setcookie(session_name(), '', time() - 42000,
		        $params["path"], $params["domain"],
		        $params["secure"], $params["httponly"]
		    );
		}
		session_destroy();
		break;
	case 'reset':
		$_SESSION['views'] = 1;
		break;	
	default:
		if (!isset($_SESSION['views'])) $_SESSION['views'] = 1;
		break;
}

?>

<html>
<body>
<h1>Deploy via Mercurial</h1>
<h2>Testing Session: Dec 17, 303</h2>
<pre>
<?php
//retrieve session data
echo "Pageviews=". $_SESSION['views'];

$path = session_save_path();
print "\nsession path: $path \n";
?>
</pre>
<p><a href="session.php">index</a> | <a href="session.php?op=add">add</a> | <a href="session.php?op=sub">sub</a> | <a href="session.php?op=reset">reset</a> | <a href="session.php?op=logout">logout</a></p>
</body>
</html>
